home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / MSDOS / (m)aan / CTUTOR2.ARC / ANYFILE.C < prev    next >
Text File  |  1986-05-27  |  512b  |  21 lines

  1. #include "stdio.h"
  2.  
  3. main()
  4. {
  5. FILE *fp1;
  6. char oneword[100],filename[25];
  7. char *c;
  8.  
  9.    printf("Enter filename -> ");
  10.    scanf("%s",filename);         /* read the desired filename */
  11.    fp1 = fopen(filename,"r");
  12.  
  13.    do {
  14.       c = fgets(oneword,100,fp1); /* get one line from the file */
  15.       if (c != NULL)
  16.          printf("%s",oneword);    /* display it on the monitor  */
  17.    } while (c != NULL);          /* repeat until NULL          */
  18.  
  19.    fclose(fp1);
  20. }
  21.